﻿@using Happy.Query;
@using Happy.Cms.Query.Articles
@using Happy.ExtentionMethods;
@model  PageResult<ArticleView>

@foreach (var article in this.Model.Items)
{
    <h3><a href="/Tenoner/Article/Detail/@article.Id" title="@article.Title">@article.Title.Ellipsis(25)</a></h3>
}

<ul class="pagination">
    @{
        var start = this.Model.CurrentPage - 2;
        if (start < 1)
        {
            start = 1;
        }
        var end = start + 4;
        if (end > this.Model.TotalPages)
        {
            end = this.Model.TotalPages;
        }

        var preClass = start == 1 ? "disabled" : "";
        var nextClass = start == 1 ? "disabled" : "";
    }
    <li class="@preClass">@Html.ActionLink("<", "Index", new { page = start - 1 })</li>
    @for (var i = start; i <= end; i++)
    {
        var activeClass = i == this.Model.CurrentPage ? "active" : "";
        <li class="@activeClass">@Html.ActionLink(i.ToString(), "Index", new { page = i })</li>
    }
    <li class="@preClass">@Html.ActionLink(">", "Index", new { page = end + 1 })</li>
</ul>
